package com.cskaoyan._12io._02charstream._01filereader;

import java.io.FileReader;
import java.io.IOException;

/**
 * @author Macro_Ray
 * @since 2024/3/26 14:24
 */
// 带参的read()方法可以一次读取多个字符
public class FileReaderDemo2 {
    public static void main(String[] args) throws IOException {
        // 1.创建对象
        FileReader fr = new FileReader("Day17_Code\\b.txt");
        // 2.读取文件内容
        char[] chars = new char[4];
        int len;
        while ((len = fr.read(chars)) != -1) {
            System.out.println(new String(chars, 0, len));
        }
        // 3.关闭资源
        fr.close();

    }
}
